<div class="tableform widgetconfig">
  <h4>板块基础设置</h4> 
  <div class="division">
  	<table width="100%" cellpadding="0" cellspacing="0">
	    <tr>
          <th>版块class</th>
          <td><input class="inputstyle" type="text" name="class" value="<{$setting.class}>" style="width:150px" /> &nbsp;&nbsp;<i>可不填</i></td>
          <th>在图片下显示说明</th>		  
          <td><input type="checkbox" name="showtxt" value="1" <{if $setting.showtxt=="1"}> checked="checked"<{/if}>>&nbsp;&nbsp;板块均分显示	  
         <input type="checkbox" name="showcol" value="1" <{if $setting.showcol=="1"}> checked="checked"<{/if}>></td>		   
        </tr>
        <tr>
          <th>版块标题</th>
          <td><input class="inputstyle" type="text" name="title" value="<{$setting.title}>" style="width:150px" />&nbsp;&nbsp;<i>留空则不显示标题项</i></td>
		  <th>版块标题图片</th>
          <td><input type=hidden name="ad_pic" value="<{$setting.ad_pic}>"><input name='ad_pic' class="imgsrc inputstyle" id="ad_pic" value="<{$setting.ad_pic}>"><input type=button value="<{t app='b2c'}>上传图片<{/t}>" class="uploadbtn" onclick="addPic()">&nbsp;&nbsp;<i>不填则显示文字标题</i></td>
        </tr>
		<tr>
				<th>更多文字重定义：</th>
				<td><input type="text" name="moretext" value="<{$setting.moretext|default:更多}>" style="width:200px" class="inputstyle" /></td>
				<th>更多链接地址</th>
				<td><input type="text" name="morelink" value="<{$setting.morelink}>" style="width:200px" class="inputstyle" />不填则不显示</td>
			</tr>
    </table>
  </div>
  <div class="clearfix">
  	<{button label=$___b2c="添加图片广告"|t:'b2c' app="desktop" icon="btn_add.gif" id="add_ad_pic" onclick=""}>
 </div>
 
  <div class="division" style="margin-top:8px;" id="ad">
  <{foreach from=$setting.ad item=data key=key}>
    <div id="ad_<{$data.i}>" class="configad">
      <table width="100%" cellpadding="0" cellspacing="0">
        <input type=hidden name=ad[<{$data.i}>][type] value="<{$data.type}>">
        <input type=hidden name=ad[<{$data.i}>][i] value="<{$data.i}>">
        <tr>
          <th width="20%">图片地址:</th>
          <td><input type="text" style="width:60%" class="imgsrc inputstyle" name=ad[<{$data.i}>][link] id="ad[<{$data.i}>][link]" value="<{$data.link}>" />
			<input type="button" value="上传图片" onclick="addPic($('ad[<{$data.i}>][link]'))" />
			<span onclick="delLink(this);"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt="删除" title="删除" app="desktop"}></span>
		</td>
        </tr>
        <tr>
          <th width="20%">链接地址:</th>
          <td><input class="inputstyle" type="text" style="width:60%" name=ad[<{$data.i}>][tolink] value="<{$data.tolink}>"></td>
          <td></td>
        </tr>
        <tr>
          <th width="20%">广告说明:</th>
          <td><input class="inputstyle" type="text" style="width:60%" name=ad[<{$data.i}>][text] value="<{$data.text}>"></td>
          <td></td>
        </tr>

      </table>
    </div>
    <{/foreach}>
    </div>
</div>

<script>
$('add_ad_pic').addEvent('click',function(){
  var d=new Date();
  var i=d.getTime();
  $('ad').adopt(new Element('div').set('html','\
    <div class="configad" style="margin-top:6px;">\
       <table cellpadding="0" cellspacing="0">\
         <tr><th width=20%>图片地址:</th><td><input type="text" style="width:60%" class="imgsrc inputstyle" name=ad['+i+'][link] id="ad['+i+'][link]" value="%THEME%/images/" size=15><input type="button" value="上传图片" onClick="addPic($(\'ad['+i+'][link]\'))"><span onclick="delLink(this);"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt="删除" title="删除" app="desktop"}></span></td>\
		 </tr>\
          <tr><th>链接地址:</th><td><input class="inputstyle" type="text" style="width:60%" name=ad['+i+'][tolink] size=15></td><td></td></tr>\
		  <tr><th>广告说明：</th><td><input class="inputstyle" type="text" style="width:60%" name=ad['+i+'][text]></td><td></td></tr>\
       </table>\
      <input type=hidden name=ad['+i+'][i] value="'+i+'">\
      <input type=hidden name=ad['+i+'][type] value="image">\
    </div>\
  ').getFirst());
	$('pic['+i+']').addEvent('click',function(e){bindevent(this)});
});

function addPic(target){
	var url='index.php?app=desktop&act=alertpages&goto='+encodeURIComponent("index.php?app=image&ctl=admin_manage&act=image_broswer&type=big");
	Ex_Loader('modedialog',function(){
		return new imgDialog(url,{onCallback:function(image_id,image_src){
				$(target).value=image_src;
		}})	;
	});
}	

delLink=function(o){$(o).getParent('.configad').remove();}
</script>
